package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import com.alibaba.fastjson.JSONArray;
import com.frogs.framework.util.StringUtil;
import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.util.ApplicablePlatformEnum;
import com.frogs.system.util.PromotionApplicablePlatformEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

public class UserShoppingCartBatchAddRequest extends Request {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7218492829337403848L;

	/**
	 * 购物车id
	 */
    private int shoppingCartId = 0;

    private int userId = 0;

    private int applicablePlatformId = ApplicablePlatformEnum.WEB.getId();
    
    private int subApplicablePlatformId = PromotionApplicablePlatformEnum.NEW_MALL.getId();
    
    private String userTraceId ; 
    
    private String expandCode;
    
    private String subExpandCode;
    
    /**
	 * 评价json数组<br>
	 * 例：<br>
	 * [{<br>
	 * &nbsp;&nbsp;		originalGoodsId:原始商品ID 必传(int),<br>
	 * &nbsp;&nbsp;		goodsId:商品ID 必传(int),<br>
	 * &nbsp;&nbsp;		skuId:商品评分 (int),<br>
	 * &nbsp;&nbsp;		productCode: (String),<br>
	 * &nbsp;&nbsp;		number:(int),<br>
	 * &nbsp;&nbsp;		numberUpperLimit:(int),<br>
	 * &nbsp;&nbsp;		numberLowerLimit:(int)<br>
	 * &nbsp;&nbsp;		createType:(int)<br>
	 * &nbsp;&nbsp;		isChecked:(int)<br>
	 * &nbsp;&nbsp;		goodsStatus:(int)<br>
	 * &nbsp;&nbsp;		specialAttr:(String)<br>
	 * &nbsp;&nbsp;		merchantId:(int)<br>
	 * &nbsp;&nbsp;		familyMemberId:(int)<br>
	 * &nbsp;&nbsp;		autoprompting:(String)<br>
	 * &nbsp;&nbsp;		salesMode:(String)<br>
	 * &nbsp;&nbsp;		remark:(String)<br>
	 * &nbsp;&nbsp;		iconLabel:(String)<br>
	 * &nbsp;&nbsp;		mealId:(int)<br>
	 * &nbsp;&nbsp;		price:(double)<br>
	 * &nbsp;&nbsp;		brandId:(int)<br>
	 * &nbsp;&nbsp;		tags:(String)<br>
	 * &nbsp;&nbsp;		catIds:(String)<br>
	 * &nbsp;&nbsp;		isSeckill:(int)<br>
	 * }]<br>
	 */
    private String goods;

	@Override
	public void parse(HttpServletRequest request) {
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		

		this.shoppingCartId = requestInfo.getIntParameter(ApiUrlParamEnum.shoppingCartId.getParamName(),0);
		if(shoppingCartId < 0 ){
			shoppingCartId = 0;
		}
		
		this.userId = requestInfo.getIntParameter(ApiUrlParamEnum.userId.getParamName());
		this.userTraceId = requestInfo.getParameter(ApiUrlParamEnum.userTraceId.getParamName(), "");
		
		if ( userId <1 && StringUtil.isEmpty(userTraceId)) {
			throw new RequestIllegalException("error userId:"+userId +" or userTraceId is null");
		}
		
		this.applicablePlatformId = requestInfo.getIntParameter(ApiUrlParamEnum.applicablePlatformId.getParamName() , ApplicablePlatformEnum.WEB.getId());
		this.expandCode = requestInfo.getParameter(ApiUrlParamEnum.expandCode.getParamName(), "0");
		this.subExpandCode = requestInfo.getParameter(ApiUrlParamEnum.subExpandCode.getParamName(), "0");
		this.subApplicablePlatformId = requestInfo.getIntParameter(ApiUrlParamEnum.subApplicablePlatform.getParamName(), PromotionApplicablePlatformEnum.NEW_MALL.getId());
		this.goods = requestInfo.getParameter(ApiUrlParamEnum.goods.getParamName(), "");
		if (StringUtil.isEmpty(goods) || StringUtil.isEmpty(JSONArray.parseArray(goods))) {
			throw new RequestIllegalException("error goods:" + goods);
		}
	}

	public int getShoppingCartId() {
		return shoppingCartId;
	}

	public void setShoppingCartId(int shoppingCartId) {
		this.shoppingCartId = shoppingCartId;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public int getApplicablePlatformId() {
		return applicablePlatformId;
	}

	public void setApplicablePlatformId(int applicablePlatformId) {
		this.applicablePlatformId = applicablePlatformId;
	}

	public String getUserTraceId() {
		return userTraceId;
	}

	public void setUserTraceId(String userTraceId) {
		this.userTraceId = userTraceId;
	}

	public String getExpandCode() {
		return expandCode;
	}

	public void setExpandCode(String expandCode) {
		this.expandCode = expandCode;
	}

	public int getSubApplicablePlatformId() {
		return subApplicablePlatformId;
	}

	public void setSubApplicablePlatformId(int subApplicablePlatformId) {
		this.subApplicablePlatformId = subApplicablePlatformId;
	}

	public String getSubExpandCode() {
		return subExpandCode;
	}

	public void setSubExpandCode(String subExpandCode) {
		this.subExpandCode = subExpandCode;
	}

	public String getGoods() {
		return goods;
	}

	public void setGoods(String goods) {
		this.goods = goods;
	}
	
}
